﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using SeizyUtils.Common.Utilities;

namespace SeizyUtils.Common.Data.Database.Parse
{
    class UsingState : IParseState
    {
        private readonly StringBuilder iUsingClause;

        public UsingState()
        {
            iUsingClause = new StringBuilder();
        }

        public IParseState ReadLine(string line, StringBuilder resultSql, QueryParam param)
        {
            if (line.StartsWith("[using end]"))
            {
                resultSql.Append("\n ");
                resultSql.Append(iUsingClause.ToString());
                return new ReadState();
            }

            //パラメータを置換する
            iUsingClause.Append(QueryParser.replaceParam(line, param));

            return this;
        }

    }
}
